home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / executeCmdOnItems.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  1.8 KB  |  56 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. global proc string[] executeCmdOnItems(
  18.     string $cmd,
  19.     string $items[] )
  20. //
  21. //  Description :
  22. //      Execute the cmd given the selection items it requires.
  23. //      The results generated on one such execution is returned
  24. //      in a string array.
  25. //        The cmd has place holders $1, $2 ... which get
  26. //        substituted by strings in items array. 
  27. //    NOTE : see appendToCmdPlaceHoldersForSelectionItems.mel
  28. //
  29. {
  30.     int $count = size($items) ;
  31.     string $pattern, $item;
  32.     int $i ;
  33.  
  34.     string $tmpCmd = $cmd ;
  35.     string $tmpCmd1 = $cmd ;
  36.     for( $i = 0 ; $i < $count ; $i++ ) {
  37.         $pattern = "%$i";
  38.         $item = $items[$i];
  39.         if( "" != $item ) {
  40.             $tmpCmd = `substitute $pattern $tmpCmd1 ( "\"" +$item + "\"")`;
  41.         }
  42.         else {
  43.             $tmpCmd = `substitute $pattern $tmpCmd1 $item`;
  44.         }
  45.         $tmpCmd1 = $tmpCmd ;
  46.     }
  47.  
  48.     // evaluate the command.
  49.     //
  50.     string $results[] ;
  51.     if( catch( $results = evalEcho($tmpCmd) ) ) {
  52.     }
  53.     return $results ;
  54. }
  55.  
  56.